import axios from 'axios';
//查询所有取货地址
export async function getAllPositions(page, pageSize, type, value) {
    let resp = await axios.get("/api/pisitions", {
        params: {
            current: page, //第几页 1234
            pageSize, //每页显示条数
            type,
            value

        }
    });
    console.log("resp", resp);
    return resp.data;
}

//查询对应的用户
export async function getOneUsers(type, value) {
    let resp = await axios.get("/api/pisitions", {
        params: {
            type,
            value
        }
    });
    console.log("resp", resp);
    return resp.data;
}

//新增取货地址
export async function getAddPositions(object) {
    let { name, pisition, notes } = object;
    let resp = await axios.post("/api/pisitions", {
        name, pisition, notes
    });
    console.log("resp", resp);
    return resp.data;
}

//通过id删除一个取货地址
export async function deleteById(_id) {
    let resp = await axios.delete("/api/pisitions/" + _id);
    console.log("resp", resp);
    return resp.data;
}



//通过id修改一个取货地址
export async function changeById(object) {
    let { _id, name, pisition, notes } = object;
    let resp = await axios.put("/api/pisitions/" + _id, {
        name, pisition, notes
    });
    console.log("resp", resp);
    return resp.data;
}


